﻿using System.Collections.Generic;
using UnityEngine;

namespace WentStateMachine {
    public class MonobehaviourRuntimeDriver : MonoBehaviour, IDriver
    {
        private List<StateMachineController> controllers = new List<StateMachineController>();

        public IStateMachineController Drive(StateMachineController asset)
        {
            var instance = ScriptableObject.Instantiate<StateMachineController>(asset);
            instance.Init();
            controllers.Add(instance);
            return instance;
        }

        private void Update()
        {
            if (controllers == null)
                return;
   
            foreach (var control in controllers)
            {
                //do
                //{
                    control.OnUpdate();

                //} while (control.ParamHasChanged);
            }
        }
    }
}
